package io.lkt.modules.sys.service.impl;

import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;

import io.lkt.modules.sys.dao.BBusinessDetailsDao;
import io.lkt.modules.sys.entity.BBusinessDetailsEntity;
import io.lkt.modules.sys.service.BBusinessDetailsService;


@Service("bBusinessDetailsService")
public class BBusinessDetailsServiceImpl extends ServiceImpl<BBusinessDetailsDao, BBusinessDetailsEntity> implements BBusinessDetailsService {
    @Autowired
    private BBusinessDetailsDao bBusinessDetailsDao;

    @Override
    @DataSource("master")
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BBusinessDetailsEntity> page = this.page(
                new Query<BBusinessDetailsEntity>().getPage(params),
                new QueryWrapper<BBusinessDetailsEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    @DataSource("master")
    public BBusinessDetailsEntity queryOne(BBusinessDetailsEntity bBusinessDetails) {
        return this.bBusinessDetailsDao.queryOne(bBusinessDetails);
    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param bBusinessDetails 实例对象
     * @return 对象列表
     */
    @Override
    @DataSource("master")
    public List<BBusinessDetailsEntity> queryAll(BBusinessDetailsEntity bBusinessDetails) {
        return this.bBusinessDetailsDao.queryAll(bBusinessDetails);
    }

    @Override
    @DataSource("master")
    public void updateByBusinessId(BBusinessDetailsEntity bBusinessDetails) {
        this.bBusinessDetailsDao.updateByBusinessId(bBusinessDetails);
    }

    @DataSource("master")
    public BBusinessDetailsEntity getById(Serializable id)
    {
        return (BBusinessDetailsEntity)((BBusinessDetailsDao)this.baseMapper).selectById(id);
    }

    @DataSource("master")
    public boolean save(BBusinessDetailsEntity entity)
    {
        return retBool(Integer.valueOf(((BBusinessDetailsDao)this.baseMapper).insert(entity)));
    }

    @DataSource("master")
    public boolean updateById(BBusinessDetailsEntity entity)
    {
        return retBool(Integer.valueOf(((BBusinessDetailsDao)this.baseMapper).updateById(entity)));
    }

}
